/**
* @file		ResMgr.ixx
* @brief	资源模板
*
*
* @version	1.0
* @author	lveyou
* @date		22-03-08
*
*/

export module ResMgr;

import DND;

import DefVar;
import DefOrder;

export class ResMgr
{
public:
	ResMgr()
	{
		
	}

	//! 普通ui文本
	Text* CreateTextNormal()
	{
		Text* ret = g_factory->CreateTextPointer(1, 16);
		ret->SetColor(0x292929ff_c);
		
		return ret;
	}

	//! 标题ui文本
	Text* CreateTextTitle()
	{
		Text* ret = g_factory->CreateTextPointer(2, 18);
		ret->SetColor(0x292929ff_c);

		return ret;
	}

	//! 旗帜文本
	gcText CreateTextFlag()
	{
		gcText ret = g_factory->CreateText(3, 24);
		return ret;
	}

	//! 区域文本
	Text* CreateTextArea()
	{
		Text* ret = g_factory->CreateTextPointer(1, 30);
		ret->SetOutline(1);
		ret->SetOrder(DefOrder::MAP_UI);

		return ret;
	}

	//! 地图文本（定居点）
	Text* CreateTextMap()
	{
		Text* ret = g_factory->CreateTextPointer(2, 24);
		ret->SetOutline(1);
		ret->SetOrder(DefOrder::MAP_UI);

		return ret;
	}

	//! 时间ui文本
	Text* CreateTextAge(bool small)
	{
		if (small)
		{
			Text* ret = g_factory->CreateTextPointer(1, 24);
			ret->SetColor(0x292929ff_c);

			return ret;
		}
		else
		{
			Text* ret = g_factory->CreateTextPointer(1, 32);
			ret->SetColor(0x292929ff_c);

			return ret;
		}
	}

	//! 变色文本按钮
	UI::ButtonTextColor* CreateButtonText()
	{
		UI::ButtonTextColor* ret = UI::ButtonTextColor::Create(
			g_factory->CreateTextPointer(2, 16),
			0x087700ff_c,
			0xff0000ff_c,
			0x0006f1ff_c,
			0x949494ff_c);

		return ret;
	}

	//! 普通按钮
	UI::ButtonSprite4Text* CreateButtonNormal()
	{
		Text* txt = g_factory->CreateTextPointer(2, 16);
		UI::ButtonSprite4Text* ret = UI::ButtonSprite4Text::Create(
			g_factory->CreateSpriteMulti("btn", 4), txt, 
			{ 0x087700ff_c,
			0xff0000ff_c,
			0x0006f1ff_c,
			0x949494ff_c }, {}, {0, -1}, { 0, 0 });

		return ret;
	}

	//! 关闭按钮
	UI::ButtonSprite4* CreateButtonClose()
	{
		UI::ButtonSprite4* ret = UI::ButtonSprite4::Create(g_factory->CreateSpriteMulti("btn_close", 4));
		return ret;
	}

	//! 开关
	UI::ButtonSprite4* CreateSwitch()
	{
		UI::ButtonSprite4* ret = UI::ButtonSprite4::Create(
			g_factory->CreateSpriteMulti("switch", 4));
		ret->SetMode(UI::Control::Mode::SWITCH);
		return ret;
	}

	//! 输入框
	UI::EditBoxNormal* CreateEditBox()
	{
		Text* txt = g_factory->CreateTextPointer(1, 16);

		UI::ButtonSprite4Text* btn = UI::ButtonSprite4Text::Create(
			g_factory->CreateSpriteMulti("editbox", 4),
			txt,
			{ DefVar::COLOR_TEXT_EDITBOX_NORMAL, DefVar::COLOR_TEXT_EDITBOX_SELECT });

		UI::EditBoxNormal* ret = UI::EditBoxNormal::Create(btn, txt);
		return ret;
	}

	//! 下拉框
	UI::ListBox* CreateListBox()
	{
		UI::ButtonSprite4* btn = UI::ButtonSprite4::Create(
			g_factory->CreateSpriteMulti("listbox", 4));
		Text* txt = CreateTextNormal();
		Sprite9* spr9 = new Sprite9("bg_1");
		gcSprite spr = g_factory->CreateSpriteDefault(ColorDef::WHITE);
		UI::ListBox* lst = UI::ListBox::Create(btn, txt, spr9, spr,
			{ 8, 0 }, { 8, 0 }, { 5, 5 }, {20, 0});
		return lst;
	}

	//! 消息框
	Tool::MsgBox* CreateMsgBox(string_view str)
	{
		Sprite9* bg = new Sprite9("bg_2");
		Text* txt_title = CreateTextTitle();
		Text* txt = CreateTextNormal();
		txt->SetFormat(true);
		UI::ButtonSprite4Text* btn = CreateButtonNormal();
		UI::ButtonSprite4* btn_close = CreateButtonClose();
		Tool::MsgBox* msg_box = Tool::MsgBox::Create(
			bg, txt_title, txt, btn, btn_close, 20.0, {-16, -16}, {36, 40});
		msg_box->Set(str);
		msg_box->SetOrder(DefOrder::UI_MSG_BOX);
		return msg_box;
	}

private:
};

export ResMgr* g_res;

module: private;
